import matplotlib.pyplot as plt
import numpy as np
import tkinter as tk
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

x = np.linspace(-3, 3, 20)
y1 = x*2+1
y2 = x**2

fig1=plt.figure(num=1,figsize=(6,4),dpi=100)

ax1=fig1.add_subplot(2,2,1)
ax2 = fig1.add_subplot(2, 2, 2)

ax1.plot(x, y1)
# ax1.scatter(x,y1)
ax1.set_xlabel("x轴")
ax1.set_ylabel("yyy")
ax1.set_title("xxx-yyy")

ax2.bar(x, y2)
# plt.show()
win=tk.Tk()
win.title("tk and matplotlib测试")
# canvs=tk.Canvas(win)
canvas = FigureCanvasTkAgg(fig1, master=win)
canvas.get_tk_widget().pack()

win.mainloop()
